package com.qingrongby.shop;

import java.util.concurrent.TimeUnit;

public class WaitAndNotify {

    public static void main(String[] args){
        Object co = new Object();
        System.out.println(co);
        for (int i=0;i<5;i++){
            MyThread t=new MyThread("Thread"+i,co);
            t.start();
        }
        try{
            TimeUnit.SECONDS.sleep(2);
            System.out.println("----Main Thread");
            synchronized (co){
                co.notifyAll();
            }
            TimeUnit.SECONDS.sleep(2);
            System.out.println("Main Thread is end");
        }catch (InterruptedException e){
            e.printStackTrace();
        }


    }

}
